package cn.zymall.goods.controller;

import cn.zymall.common.controller.crud.BaseController;
import cn.zymall.common.model.ServiceEnsure;
import cn.zymall.common.model.SpuServiceCenter;
import cn.zymall.goods.service.ServiceEnsureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lxh
 * @Description TODO
 * @date 2020/8/20 10:18
 * @Classname ServiceEnsureController
 **/
@RestController
@RequestMapping("/serviceEnsure")
public class ServiceEnsureController extends BaseController<ServiceEnsureService, ServiceEnsure> {

	@Autowired
	private ServiceEnsureService serviceEnsureService;

	@GetMapping("/findAll")
	public List<ServiceEnsure> findAll() {
		return serviceEnsureService.findAll();
	}


	/**
	 * 添加商品与服务保证的中间表数据
	 * @param spuServiceCenter
	 */
	@PostMapping("/addServiceCenter")
	public void addServiceCenter(SpuServiceCenter spuServiceCenter){
		System.out.println(spuServiceCenter);
		serviceEnsureService.addServiceCenter(spuServiceCenter);
	}


	/**
	 * 根据id删除商品服务中间表数据
	 * @param id
	 */
	@DeleteMapping("/del/{id}")
	public void del(@PathVariable(name = "id") Integer id){
		serviceEnsureService.del(id);
	}

}
